home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / networke / xfirepow.000 / xfirepow / xfirepower-0.84 / client / libsprite / cursor.c < prev    next >
C/C++ Source or Header  |  1995-05-23  |  2KB  |  107 lines

  1.  
  2. #include "allincludes.h"
  3.  
  4. Cursor
  5. make_cursor(bits, mask, width, height, xhot, yhot)
  6.     char   *bits, *mask;
  7.     unsigned int width, height, xhot, yhot;
  8. {
  9.     Pixmap  cursbits;
  10.     Pixmap  cursmask;
  11.     XColor  whiteCol, blackCol;
  12.     Cursor  curs;
  13.  
  14.     whiteCol.pixel = colortable[W_White].pixelValue;
  15.     XQueryColor(W_Display, W_Colormap, &whiteCol);
  16.     blackCol.pixel = colortable[W_Black].pixelValue;
  17.     XQueryColor(W_Display, W_Colormap, &blackCol);
  18.  
  19.     cursbits = XCreateBitmapFromData(W_Display, DefaultRootWindow(W_Display),
  20.                      bits, width, height);
  21.     cursmask = XCreateBitmapFromData(W_Display, DefaultRootWindow(W_Display),
  22.                      mask, width, height);
  23.  
  24.     curs = XCreatePixmapCursor(W_Display, cursbits, cursmask,
  25.                    &whiteCol, &blackCol, xhot, yhot);
  26.  
  27.     XFreePixmap(W_Display, cursbits);
  28.     XFreePixmap(W_Display, cursmask);
  29.     return curs;
  30. }
  31.  
  32. void
  33. W_DefineTCrossCursor(window)
  34.     W_Window window;
  35. {
  36.     return;
  37. }
  38.  
  39. void
  40. W_DefineTextCursor(window)
  41.     W_Window window;
  42. {
  43.     static Cursor new = 0;
  44.     struct window *win = W_Void2Window(window);
  45.     XColor  f, b;
  46.  
  47.     if (!new) {
  48.     f.pixel = colortable[W_Yellow].pixelValue;
  49.     b.pixel = colortable[W_Black].pixelValue;
  50.  
  51.     XQueryColor(W_Display, W_Colormap, &f);
  52.     XQueryColor(W_Display, W_Colormap, &b);
  53.  
  54.     new = XCreateFontCursor(W_Display, XC_xterm);
  55.  
  56.     XRecolorCursor(W_Display, new, &f, &b);
  57.     }
  58.     XDefineCursor(W_Display, win->window, new);
  59.  
  60.     return;
  61. }
  62.  
  63. void
  64. W_RevertCursor(window)
  65.     W_Window window;
  66. {
  67.     struct window *win = W_Void2Window(window);
  68.  
  69.     XDefineCursor(W_Display, win->window, win->cursor);
  70.  
  71.     return;
  72. }
  73.  
  74. void
  75. W_DefineCursor(window, width, height, bits, mask, xhot, yhot)
  76.     W_Window window;
  77.     int     width, height, xhot, yhot;
  78.     char   *bits, *mask;
  79. {
  80.     return;
  81. }
  82.  
  83. Cursor cursor;
  84.  
  85. void W_BlankCursor(window)
  86.      W_Window window;
  87. {
  88.     struct window *win = W_Void2Window(window);
  89.     
  90.     XColor color;
  91.     Pixmap cursorPixmap;
  92.     
  93.     color.pixel = WhitePixel(W_Display, DefaultScreen(W_Display));
  94.     XQueryColor(W_Display, 
  95.         DefaultColormap(W_Display, DefaultScreen(W_Display)), &color);
  96.     
  97.     /* Free old cursor */
  98.     if (cursor) XFreeCursor(W_Display, cursor);
  99.  
  100.     cursorPixmap = XCreatePixmap(W_Display, win->window, 1, 1, 1);
  101.     cursor = XCreatePixmapCursor(W_Display, 
  102.                  cursorPixmap, cursorPixmap, &color, &color, 0, 0);
  103.     if (cursorPixmap) XFreePixmap(W_Display, cursorPixmap);
  104.     
  105.     XDefineCursor(W_Display, win->window, cursor);
  106. }
  107.